﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 加工记录表
    /// </summary>
    [Verify]
    [Route("business/CksWorkRecord")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksWorkRecordController : BaseController
    {
        /// <summary>
        /// 工位表接口
        /// </summary>
        private readonly ICksWorkRecordService _CksWorkStationService;

        public CksWorkRecordController(ICksWorkRecordService CksWorkStationService)
        {
            _CksWorkStationService = CksWorkStationService;
        }

        /// <summary>
        /// 查询工位表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [AllowAnonymous]
        public IActionResult QueryCksWorkStation([FromQuery] CksWorkRecordQueryDto parm) {
            var response = _CksWorkStationService.GetList(parm);
            return SUCCESS(response);
        }


        [HttpPost("workStationReWork")]
        [ActionPermissionFilter(Permission = "cksworkrecord:rework")]
        [Log(Title = "工件返工", BusinessType = BusinessType.UPDATE)]
        public IActionResult WorkStationReWork([FromBody] List<CksWorkRecord> parm) {
            (bool isSuccess,string errorMsg) response = _CksWorkStationService.WorkStationReWork(parm);
            Dictionary<string, object> keys = new Dictionary<string, object>();
            keys.Add("isSuccess", response.isSuccess);
            keys.Add("errorMsg", response.errorMsg);
            return SUCCESS(keys);
        }

    }
}